﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LogisticsAdmin.DAL
{
    public class UserDAL
    {

        public object IsAccount(string account)
        {
            string sql = "select * from   [User]  where Account=@account";
            SqlParameter[] para = {
            new SqlParameter("@account",account)
            };
            object result = SQLHelper.ExecuteScalar(sql, para);
            return result;
        }
        public object IsTel(string tel)
        {
            string sql = "select * from   [User]  where Phone=@tel";
            SqlParameter[] para = {
            new SqlParameter("@tel",tel)
            };
            return SQLHelper.ExecuteScalar(sql, para);
        }

        public int Reg(string account, string tel, string pwd, string name)
        {
            string sql = @"insert into [User](UserName,Sex,Account,Password,Phone,Email,FK_RoleID,CheckInTime,IsDelete,AlterTime)
  values(@name, 0, @account, @pwd, @tel, '13@qq.com', 1, getdate(), 0, getdate())";
            SqlParameter[] para = {
                 new SqlParameter("@account",account),
                 new SqlParameter("@tel",tel),
                 new SqlParameter("@pwd",pwd),
                 new SqlParameter("@name",name)
            };
            return SQLHelper.ExecuteNonQuery(sql, para);
        }
    }
}
